//
//  ShowMessage.swift
//  fho
//
//  Created by 郭颢源 on 2021/3/30.
//

import Foundation

class JSShowMessage {
    
    static let shareMessage = JSShowMessage()
    /// 重写init 禁止外部初始化
    private init(){}
   
    static func showTipMsg(_ msg: String ,time: Double)  {
        DispatchQueue.main.async {
            let hud = MBProgressHUD.showAdded(to: UIApplication.shared.windows.first!, animated: true)
            hud.mode = .text
            hud.label.text = msg
            hud.margin     = 10 // HUD各元素与HUD边缘的间距
            hud.offset.y   = -66 // HUD相对于父视图中心点的x轴偏移量和y轴偏移量
            hud.removeFromSuperViewOnHide = true
            hud.hide(animated: true, afterDelay: time)
        }
    }
    
    //显示菊花框
    static func showTip(msg : String){
//        DispatchQueue.main.async(execute: {
//
//           })
        
        DispatchQueue.main.async {
            MBProgressHUD.showAdded(to: UIApplication.shared.windows.first!, animated: true).label.text = msg
        }
        
    }
    //隐藏菊花框
    static func hidenTip(){
        DispatchQueue.main.async {
            MBProgressHUD.hide(for: UIApplication.shared.windows.first!, animated: true)
        }
        
    }
}
